<%= simple_form_for @purchase do |f| %>

<% if @purchase.errors.any? %>
<div id="error_explanation">
	<h2><%= pluralize(@purchase.errors.count, "error") %> prohibited this invoice from being saved:</h2>

	<ul>
		<% @purchase.errors.full_messages.each do |msg| %>
		<li>
			<%= msg %>
		</li>
		<% end %>
	</ul>
</div>
<% end %>


<%= f.input :user_id, as: :hidden, :input_html => { :value => current_user.id }  %>


<table class="table table-striped table-bordered" >
	<thead>
		<tr>
			<th> Item</th>
			<th> Size </th>
			<th> Qty </th>
			<th></th>
		</tr>
	</thead>
	<tbody>

		<%= f.simple_fields_for :purchase_items  do |task| %>
			<%= render "purchase_item_fields", :f => task %>
		<% end %>
	</tbody>
</table>

<%= link_to_add_association 'Add Item', f, :purchase_items, :data => { "association-insertion-node" => 'tbody', "association-insertion-metho" => 'append' }  %>

<p>
	<%= f.button :submit , :class => "btn btn-default"  %>
</p>
<% end %>

